package com.ljx.itbbs.server.user.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ljx.itbbs.server.user.domain.entity.UserPlateRelationEntity;
import com.ljx.itbbs.server.user.mapper.UserPlateRelationMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserPlateRelationDao extends ServiceImpl<UserPlateRelationMapper, UserPlateRelationEntity> {

    public List<UserPlateRelationEntity> getPlateListByUId(Long userId) {
        return lambdaQuery().eq(UserPlateRelationEntity::getUid, userId).list();
    }

    public List<UserPlateRelationEntity> getPlateListByPlateId(Long plateId) {
        return lambdaQuery().eq(UserPlateRelationEntity::getPlateId, plateId).list();
    }

    public void delete(Long plateId, Long uid) {
        this.baseMapper.delete(new LambdaQueryWrapper<UserPlateRelationEntity>()
                .eq(UserPlateRelationEntity::getPlateId, plateId)
                .eq(UserPlateRelationEntity::getUid, uid));
    }
}
